package Exercise2;
//定义数组存储4个女朋友的对象
//商品的属性:姓名,年龄，性别，爱好
//1.计算出四个女朋友的平均年龄
//2.统计年龄比平均值低的女朋友有几个？并把她们的所有信息打印出来。
public class GirlFriendTest {
    public static void main(String[] args) {
        GrilFriend[] arr = new GrilFriend[4];
        GrilFriend g1 = new GrilFriend("诗诗",20,'女',"打游戏");
        GrilFriend g2= new GrilFriend("丽丽",21,'女',"唱歌");
        GrilFriend g3 = new GrilFriend("雅雅",22,'女',"跳舞");
        GrilFriend g4 = new GrilFriend("爱爱",23,'女',"看书");

        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;
        arr[3] = g4;

        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            GrilFriend gf = arr[i];
            sum = sum + gf.getAge();
        }
        int avg = sum/ arr.length;

        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            GrilFriend gf = arr[i];
            if(gf.getAge()<avg){
                count++;
                System.out.println(gf.getName()+","+gf.getAge()+","+gf.getGender()+","+gf.getHobby());
            }
        }
        System.out.println(count+"个");
    }
}
